package com.zgh.action;

import com.zgh.domain.Result;
import com.zgh.util.QiniuUtil;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GetToken {
    /**
     * 上传图片到七牛云（可覆盖）
     * @param key 图片后缀名称
     * @return token
     */
  @RequestMapping(value = "/GetToken/{key}")
  public Result getQiToken(@PathVariable String key) {
      String token = QiniuUtil.getToken(key);
      return new Result(true, "获取token成功",token);
  }

    /**
     * 上传图片到七牛云
     * @param
     * @return token
     */
    @RequestMapping(value = "/GetTokenNoKey",method = RequestMethod.POST)
    public Result getTokenNoKey() {
        String token = QiniuUtil.getUploadToken();
        return new Result(true, "获取qiniuToken成功",token);
    }
}